package com.ruoyi.show.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.show.domain.PublishYearTrend;
import com.ruoyi.show.service.IPublishYearTrendService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 出版数量趋势Controller
 * 
 * @author ruoyi
 * @date 2025-09-08
 */
@RestController
@RequestMapping("/show/publishYearTrend")
public class PublishYearTrendController extends BaseController
{
    @Autowired
    private IPublishYearTrendService publishYearTrendService;

    /**
     * 查询出版数量趋势列表
     */
    @PreAuthorize("@ss.hasPermi('show:publishYearTrend:list')")
    @GetMapping("/list")
    public TableDataInfo list(PublishYearTrend publishYearTrend)
    {
        startPage();
        List<PublishYearTrend> list = publishYearTrendService.selectPublishYearTrendList(publishYearTrend);
        return getDataTable(list);
    }

    /**
     * 导出出版数量趋势列表
     */
    @PreAuthorize("@ss.hasPermi('show:publishYearTrend:export')")
    @Log(title = "出版数量趋势", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PublishYearTrend publishYearTrend)
    {
        List<PublishYearTrend> list = publishYearTrendService.selectPublishYearTrendList(publishYearTrend);
        ExcelUtil<PublishYearTrend> util = new ExcelUtil<PublishYearTrend>(PublishYearTrend.class);
        util.exportExcel(response, list, "出版数量趋势数据");
    }

    /**
     * 获取出版数量趋势详细信息
     */
    @PreAuthorize("@ss.hasPermi('show:publishYearTrend:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(publishYearTrendService.selectPublishYearTrendById(id));
    }

    /**
     * 新增出版数量趋势
     */
    @PreAuthorize("@ss.hasPermi('show:publishYearTrend:add')")
    @Log(title = "出版数量趋势", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PublishYearTrend publishYearTrend)
    {
        return toAjax(publishYearTrendService.insertPublishYearTrend(publishYearTrend));
    }

    /**
     * 修改出版数量趋势
     */
    @PreAuthorize("@ss.hasPermi('show:publishYearTrend:edit')")
    @Log(title = "出版数量趋势", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PublishYearTrend publishYearTrend)
    {
        return toAjax(publishYearTrendService.updatePublishYearTrend(publishYearTrend));
    }

    /**
     * 删除出版数量趋势
     */
    @PreAuthorize("@ss.hasPermi('show:publishYearTrend:remove')")
    @Log(title = "出版数量趋势", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(publishYearTrendService.deletePublishYearTrendByIds(ids));
    }
}
